﻿using System;
using System.Collections.ObjectModel;
using System.Xml.Serialization;
using EpiNEXT.Services.Fields.Properties;

namespace EpiNEXT.Services.Fields
{
    //[Serializable()]
    public class YesNoField : ComboBoxField, IInputField
    {
        #region Members
        private bool _includeUnknown = false;
        #endregion // Members

        #region Constructors
        public YesNoField() :
            base()
        {
            IncludeUnknown = false;
        }
        #endregion // Constructors

        #region Properties
        [XmlElement]
        public bool IncludeUnknown
        {
            get
            {
                return this._includeUnknown;
            }
            set
            {
                if (IncludeUnknown != value)
                {
                    _includeUnknown = value;
                    RaisePropertyChanged("IncludeUnknown");

                    if (this.Form != null)
                    {
                        Project project = this.Form.Owner;

                        if (IncludeUnknown)
                        {
                            this.ListSource = project.CodeListYNU;
                        }
                        else
                        {
                            this.ListSource = project.CodeListYN;
                        }
                    }
                }
            }
        }
        #endregion // Properties
    }
}
